home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / euro_grf.cpp < prev    next >
C/C++ Source or Header  |  1996-03-19  |  22KB  |  784 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <math.h>
  6.  
  7. #include "eurodefs.h"
  8. #include "euro_fxd.h"
  9. #include "euro.equ"
  10. #include "euro_sym.h"
  11. #include "euro_def.h"
  12. #include "euro_var.h"
  13. #include "euro_gen.h"
  14. #include "euro_dsk.h"
  15. #include "euro_int.h"
  16.  
  17. #include "3deng.h"
  18. //#include "video.h"
  19.  
  20. extern    int        testVESA;
  21. extern    int         VESAmode(int *);
  22. extern  void near svgacpy( char unsigned near *, short, short, short, short, short );
  23. extern    short        GetSwitch( char *buf );
  24.  
  25. //********************************************************************************************************************************
  26.  
  27. void straightcopy(int copyWidth, BYTE *dest, BYTE *srce)
  28.     {
  29.     int    x;
  30.     BYTE pixel;
  31.     for (x=0; x < copyWidth; x++)
  32.         *dest++ = *srce++;
  33.     }
  34.  
  35. void spritecopy(int copyWidth, BYTE *dest, BYTE *srce)
  36.     {
  37.     int    x;
  38.     BYTE pixel;
  39.     for (x=0; x < copyWidth; x++)
  40.         {
  41.         pixel = *srce++;
  42.  
  43.         if (pixel)
  44.             *dest = pixel;
  45.         dest++;
  46.         }
  47.     }
  48.  
  49. void flipsprcopy(int copyWidth, BYTE *dest, BYTE *srce)
  50.     {
  51.     int    x;
  52.     BYTE pixel;
  53.     srce+=    (copyWidth-1);
  54.     
  55.     for (x=0; x < copyWidth; x++)
  56.         {
  57.         pixel = *srce--;
  58.  
  59.         if (pixel)
  60.             *dest = pixel;
  61.         dest++;
  62.         }
  63.     }
  64.  
  65. void spriteinccopy(int copyWidth, BYTE *dest, BYTE *srce)
  66.     {
  67.     int    x;
  68.     BYTE pixel;
  69.     for (x=0; x < copyWidth; x++)
  70.         {
  71.         pixel = *srce++;
  72.         if (pixel)
  73.             *dest = (pixel+svalue);
  74.         dest++;
  75.         }
  76.     }
  77.  
  78. void spriteareainccopy(int copyWidth, BYTE *dest, BYTE *srce)
  79.     {                            // if a pixel falls within 'pmin' & 'pmax' then 
  80.     int    x;                        // it is increased by 'svalue'.
  81.     BYTE pixel;
  82.     for (x=0; x < copyWidth; x++)
  83.         {
  84.         pixel = *srce++;
  85.         if (pixel)
  86.         {
  87.             if ( pixel >= pmin && pixel < pmax )
  88.                 *dest = (pixel+svalue);
  89.                 else
  90.                 *dest = pixel;
  91.         }
  92.  
  93.  
  94.         dest++;
  95.         }
  96.     }
  97.  
  98. void spritefilter(int copyWidth, BYTE *dest, BYTE *srce)
  99.     {
  100.     int    x;
  101.     BYTE pixel;
  102.     for (x=0; x < copyWidth; x++)
  103.         {
  104.         pixel = *srce++;
  105.         if (pixel)
  106.             {
  107.             pixel = *dest;
  108.             *dest = ftable[pixel];
  109.             }
  110.         dest++;
  111.         }
  112.     }
  113.  
  114. void pseudostore(int copyWidth, BYTE *dest, BYTE *srce)
  115.     {
  116.     int    x;
  117.     BYTE pixel;
  118.     for (x=0; x < copyWidth; x++)
  119.         {
  120.         pixel = *dest++;
  121.         *srce = pixel;
  122.         srce++;
  123.         }
  124.     }
  125.  
  126. //********************************************************************************************************************************
  127.                                                                  
  128. void    DrawIMAGE( pseudo_info *pseudo, texture_info *texture, int image_no, int xpos, int ypos, signed char box, copyfunctiontype copyfunction )
  129.     {
  130.  
  131.     BYTE *dest = pseudo->pseudo_start + (ypos * pseudo->pseudo_width) + xpos;
  132.     BYTE *srce = texture->page_start + (texture->page_width*texture->page_height*Image_Pages[image_no] ) +
  133.             ( (texture->page_width * Image_Ycoords[image_no] ) + Image_Xcoords[image_no] );
  134.         
  135.     int copyWidth = Min( Image_Widths[image_no],  pseudo->window_width-xpos);
  136.     int copyHigh  = Min( Image_Heights[image_no], pseudo->window_height-ypos);
  137.  
  138.     if ( copyWidth < 0 || copyHigh < 0 ) return;
  139.         
  140.         if ( box>=0 )
  141.         {
  142.             if ((xpos < Bounding_table[(box)].BoundingBoxLeft) || Bounding_table[(box)].BoundingBoxLeft == -1)
  143.                 Bounding_table[(box)].BoundingBoxLeft = (short) xpos;
  144.             if ((ypos < Bounding_table[(box)].BoundingBoxTop) || Bounding_table[(box)].BoundingBoxTop == -1)
  145.                 Bounding_table[(box)].BoundingBoxTop = (short) ypos;
  146.         }
  147.  
  148.     int destAddn  =    pseudo->pseudo_width;
  149.     int srceAddn  =    texture->page_width;
  150.  
  151.     int y;
  152.  
  153.     for (y=0; y < copyHigh; y++)
  154.         {
  155.         copyfunction( copyWidth, dest, srce );
  156.         dest+=    destAddn;        
  157.         srce+=    srceAddn;        
  158.         }
  159.  
  160.             if ( box>=0 )
  161.             {
  162.                 if ( ( (xpos+Image_Widths[image_no]) > Bounding_table[(box)].BoundingBoxRight) || 
  163.                     Bounding_table[(box)].BoundingBoxRight == -1)
  164.                         Bounding_table[(box)].BoundingBoxRight = ( (short) xpos+Image_Widths[image_no] );
  165.  
  166.                 if ( ( (ypos+Image_Heights[image_no]) > Bounding_table[(box)].BoundingBoxBottom) || 
  167.                     Bounding_table[(box)].BoundingBoxBottom == -1)
  168.                         Bounding_table[(box)].BoundingBoxBottom = ( (short) ypos+Image_Heights[image_no]);
  169.             }
  170.  
  171.     }
  172.  
  173. //********************************************************************************************************************************
  174.  
  175. void    StorePSEUDObuffer( pseudo_info *pseudo, texture_info *texture, int image_no, int xpos, int ypos )
  176.     {
  177.  
  178.     BYTE *srce = pseudo->pseudo_start + (ypos * pseudo->pseudo_width) + xpos;
  179.     BYTE *dest = texture->page_start + (texture->page_width*texture->page_height*Image_Pages[image_no] ) +
  180.             ( (texture->page_width * Image_Ycoords[image_no] ) + Image_Xcoords[image_no] );
  181.         
  182.     int copyWidth = Image_Widths[image_no];
  183.     int copyHigh  = Image_Heights[image_no];
  184.  
  185.     if ( copyWidth < 0 || copyHigh < 0 ) return;
  186.         
  187.     int srceAddn  =    pseudo->pseudo_width-copyWidth;
  188.     int destAddn  =    texture->page_width-copyWidth;
  189.  
  190.     int y;
  191.  
  192.         for (y=0; y < copyHigh; y++)
  193.         {
  194.             int    x;
  195.             BYTE pixel;
  196.  
  197.             for (x=0; x < copyWidth; x++)
  198.                 {
  199.                     pixel = *srce++;
  200.                     *dest = pixel;
  201.                     dest++;
  202.                 }
  203.  
  204.             srce+=    srceAddn;        
  205.             dest+=    destAddn;        
  206.         }
  207.     }
  208.  
  209. //********************************************************************************************************************************
  210.  
  211. void    CopyFromBACKtoPSEUDObuffer( pseudo_info *pseudo, pseudo_info *background, int xpos, int ypos, short width, short height )
  212.     {
  213.  
  214.     BYTE *dest = pseudo->pseudo_start + (ypos * pseudo->pseudo_width) + xpos;
  215.     BYTE *srce = background->pseudo_start + (ypos * background->pseudo_width) + xpos;
  216.         
  217.     int srceAddn  =    background->pseudo_width-width;
  218.     int destAddn  =    pseudo->pseudo_width-width;
  219.  
  220.     int y;
  221.  
  222.         for (y=0; y < height; y++)
  223.         {
  224.             int    x;
  225.             BYTE pixel;
  226.  
  227.             for (x=0; x < width; x++)
  228.                 {
  229.                     pixel = *srce++;
  230.                     *dest = pixel;
  231.                     dest++;
  232.                 }
  233.  
  234.             srce+=    srceAddn;        
  235.             dest+=    destAddn;        
  236.         }
  237.     }
  238.  
  239. //********************************************************************************************************************************
  240.  
  241. void    CopyDumpListToScreen()
  242. {
  243.     for (short d=0; d<MAX_DUMPS; d++)
  244.     {
  245.         if ( Dump_list[d].DumpFlag!=0 )
  246.         {
  247.             svgacpy( (unsigned char *) EuroPseudoBuffer+((640*Dump_list[d].DumpYpos)+
  248.             Dump_list[d].DumpXpos),
  249.             Dump_list[d].DumpXpos , Dump_list[d].DumpYpos,
  250.             Dump_list[d].DumpWidth , Dump_list[d].DumpHeight,
  251.             640);        
  252.             Dump_list[d].DumpFlag =    0; 
  253.         }
  254.     }
  255.  
  256. }
  257.  
  258. //********************************************************************************************************************************
  259.  
  260. void    DisplayString( int xpos, int ypos, char *string, int font, int colour, signed char box, pseudo_info *pseudo, texture_info *texture )
  261.     {
  262.         int c;
  263.         svalue    =    colour;
  264.  
  265.         while    ( c=*(string++) )     
  266.             {
  267.                 c =  ASCtoImageTBL[c];
  268.                 c+=  font;
  269.                       DrawIMAGE( pseudo, texture, c, xpos, ypos, box, spriteinccopy );
  270.                 xpos+=    (Image_Widths[c])+1;
  271.             }
  272.  
  273.         NextXposn = xpos;
  274.     }
  275.  
  276. //********************************************************************************************************************************
  277.  
  278. int    PixelLengthOfString( char *string, int font )
  279.     {
  280.         int c;
  281.         int    len    =    0;
  282.  
  283.         while    ( c=*(string++) )     
  284.         {
  285.              c =      ASCtoImageTBL[c];
  286.              c+=    font;
  287.              len+=    (Image_Widths[c])+1;
  288.          }
  289.  
  290.     return(len);
  291.  
  292.     }
  293.  
  294. //********************************************************************************************************************************
  295.  
  296. void    AddToDumpList(short X,short Y,short W,short H)
  297. {
  298.     for (short a=0; a<MAX_DUMPS; a++)
  299.     {            
  300.         if (Dump_list[a].DumpFlag==0 )
  301.         {
  302.             Dump_list[a].DumpXpos    =    X;
  303.             Dump_list[a].DumpYpos    =    Y;
  304.             Dump_list[a].DumpWidth    =    W;
  305.             Dump_list[a].DumpHeight    =    H;
  306.             Dump_list[a].DumpFlag   =       1;
  307.             break;
  308.         }
  309.     }
  310. }
  311.  
  312. //********************************************************************************************************************************
  313.  
  314. void    ClearDumpList()
  315. {
  316.     for (short c=0; c<MAX_DUMPS; c++)
  317.         Dump_list[c].DumpFlag    =    0;
  318. }
  319.  
  320. //********************************************************************************************************************************
  321.  
  322. void     CreateFilter( BYTE *FilterTable, char fr, char fg, char fb, float mr, float mg, float mb )
  323.     {
  324.     signed short r1,g1,b1,r2,g2,b2;
  325.     signed short x,s,c,l1,l2,d1,d2;
  326.     if ((l1=sqrt(fr*fr+fg*fg+fb*fb))==0) l1=1;
  327.     for (x=0;x<768;x+=3)     
  328.         {
  329.         l2=sqrt(PaletteBuffer[x]*PaletteBuffer[x]+PaletteBuffer[x+1]*
  330.             PaletteBuffer[x+1]+PaletteBuffer[x+2]*PaletteBuffer[x+2]);
  331.         r1=PaletteBuffer[x]+mr*(fr*l2/l1-PaletteBuffer[x]);
  332.         if (r1<0) r1=0;if (r1>255) r1=255;
  333.         g1=PaletteBuffer[x+1]+mg*(fg*l2/l1-PaletteBuffer[x+1]);
  334.         if (g1<0) g1=0;if (g1>255) g1=255;
  335.         b1=PaletteBuffer[x+2]+mb*(fb*l2/l1-PaletteBuffer[x+2]);
  336.         if (b1<0) b1=0;if (b1>255) b1=255;
  337.         r1=(fr-PaletteBuffer[x])*mr+PaletteBuffer[x];
  338.         g1=(fg-PaletteBuffer[x+1])*mg+PaletteBuffer[x+1];
  339.         b1=(fb-PaletteBuffer[x+2])*mb+PaletteBuffer[x+2];
  340.         d1=128;
  341.  
  342.         for (s=0;s<768-16*3;s+=3)
  343.             {
  344.              r2=(PaletteBuffer[s]-r1);
  345.             g2=(PaletteBuffer[s+1]-g1);
  346.             b2=(PaletteBuffer[s+2]-b1);
  347.             d2=sqrt(r2*r2+g2*g2+b2*b2);
  348.             if (d2<d1) d1=d2,c=s;
  349.             }
  350.  
  351.         FilterTable[x/3]=c/3;
  352.         }
  353.     }
  354.  
  355. //********************************************************************************************************************************
  356.  
  357. void    ControlAnimations()
  358.     {
  359.     signed char BOX;
  360.     int width, height;
  361.  
  362.         for ( short a=0; a < MAX_ANIMATIONS; a++ )
  363.         {
  364.  
  365.         BOX    = Animation_table[a].Bounding_box;
  366.  
  367.             if ( Animation_table[a].StartFrame != -1 )
  368.             {           
  369.                 if ( Animation_table[a].Flags != 0 && BOX != NO_BOX )
  370.                 {
  371.                          width    = Bounding_table[BOX].BoundingBoxRight  - 
  372.                            Bounding_table[BOX].BoundingBoxLeft;
  373.                     height    = Bounding_table[BOX].BoundingBoxBottom - 
  374.                            Bounding_table[BOX].BoundingBoxTop;
  375.  
  376.                     CopyFromBACKtoPSEUDObuffer(
  377.                             &FrontendPseudoDEFN, &FrontendBackgroundDEFN,
  378.                             Bounding_table[BOX].BoundingBoxLeft,
  379.                             Bounding_table[BOX].BoundingBoxTop,
  380.                             width, height );
  381.                     AddToDumpList( 
  382.                             (short)Bounding_table[BOX].BoundingBoxLeft,
  383.                             (short)Bounding_table[BOX].BoundingBoxTop,
  384.                             (short)width, height );
  385.                 }
  386.  
  387.             Animation_table[a].Counter+=    Animation_table[a].AnimationSpeed;
  388.                   
  389.             if ( Animation_table[a].AnimationSpeed > 0 &&
  390.                 (Animation_table[a].StartFrame + Animation_table[a].Counter) > Animation_table[a].EndFrame )
  391.             {
  392.                 if ( (Animation_table[a].Flags & CONT_ANIM) == CONT_ANIM )
  393.                 {
  394.                     Animation_table[a].Counter-=    (Animation_table[a].EndFrame-Animation_table[a].StartFrame);
  395.                 }
  396.                 
  397.                 else
  398.  
  399.                 {
  400.                     Animation_table[a].Counter        =    0;
  401.                     Animation_table[a].AnimationSpeed    =    0;
  402.                 }
  403.             }
  404.  
  405.  
  406.  
  407.             if ( Animation_table[a].AnimationSpeed < 0 &&
  408.                 (Animation_table[a].StartFrame + Animation_table[a].Counter) < Animation_table[a].StartFrame )
  409.  
  410.                 {
  411.                     Animation_table[a].Counter+=    Animation_table[a].EndFrame-Animation_table[a].StartFrame;
  412.                 }
  413.                 
  414.             if ( Animation_table[a].AnimationSpeed < 0 
  415.                 && Animation_table[a].Counter > 0 
  416.                 && Animation_table[a].Counter + Animation_table[a].AnimationSpeed < 0 
  417.                 && ( (Animation_table[a].Flags & CONT_ANIM) == RUN_ONCE )
  418.                   )
  419.                 {
  420.                     Animation_table[a].Counter        =    0;
  421.                     Animation_table[a].AnimationSpeed    =    0;
  422.                 }
  423.  
  424.             DrawIMAGE(     &FrontendPseudoDEFN, &FrontendTextureDEFN, 
  425.                     ((int)(Animation_table[a].StartFrame+Animation_table[a].Counter)),
  426.                     Animation_table[a].xposn,
  427.                     Animation_table[a].yposn,
  428.                     BOX,
  429.                     spritecopy );      
  430.  
  431.             Animation_table[a].Flags|= 1;
  432.  
  433.             width    = Image_Widths[( (int) (Animation_table[a].StartFrame+Animation_table[a].Counter) )];
  434.             height    = Image_Heights[( (int) (Animation_table[a].StartFrame+Animation_table[a].Counter) )];
  435.  
  436.             AddToDumpList(     (short)Animation_table[a].xposn, 
  437.                     (short)Animation_table[a].yposn, 
  438.                     (short)width, (short)height );
  439.             }
  440.         }                
  441.     }    
  442.  
  443. //********************************************************************************************************************************
  444.  
  445.     int    MenuBitmaps[32]={
  446.         {BIN_MAIN},    {BIN_MAIN},    {BIN_TEAMSET},    {BIN_GRP_FIX}, 
  447.         {BIN_TEAMSEL},    {BIN_EURODRAW},    {BIN_PLYRSTAT},    {BIN_PLYRSET},
  448.         {BIN_TEAMSTAT},    {BIN_VENUEFLY},    {BIN_MODEMINI},    {BIN_NEXTMTCH},
  449.         {BIN_QUALIFY},     {BIN_QUARTFIN}, {BIN_SEMIFINL},    {BIN_FINAL}, 
  450.         {BIN_MAIN},    {BIN_MAIN},    {BIN_MAIN},    {BIN_MAIN},    
  451.         {BIN_MAIN},     {BIN_MAIN},     {BIN_MAIN},     {BIN_MAIN}, 
  452.         {BIN_MAIN},    {BIN_MAIN},    {BIN_MAIN},    {BIN_MAIN},    
  453.         {BIN_MAIN},     {BIN_MAIN},     {BIN_MAIN},     {BIN_MAIN}, 
  454.                    };
  455.     int    MenuPalettes[32]={
  456.         {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_TSETPAL},    {BIN_GFIXPAL},
  457.         {BIN_TSELPAL},    {BIN_DRAWPAL},    {BIN_PSTATPAL},    {BIN_PSETPAL},
  458.         {BIN_TSTATPAL},    {BIN_VNFLYPAL},    {BIN_MDSETPAL},    {BIN_NMTCHPAL},
  459.         {BIN_QUALYPAL},    {BIN_QUTFNPAL},    {BIN_SEMFPAL},    {BIN_FINALPAL},
  460.         {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},
  461.         {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},
  462.         {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},
  463.         {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},    {BIN_MAINPAL},
  464.                    };
  465.  
  466.     int    FormationPalettes[16]={
  467.         {BIN_FBGREEN},    {BIN_FDORAN},    {BIN_FRED},    {BIN_FRED},   
  468.         {BIN_FBBLUE},     {BIN_FLBLUE},     {BIN_FRED},     {BIN_FBORAN},
  469.         {BIN_FBBLUE},      {BIN_FRED},       {BIN_FRED},     {BIN_FBBLUE}, 
  470.         {BIN_FBBLUE},     {BIN_FRED},       {BIN_FRED},     {BIN_FRED},
  471.                    };
  472.  
  473.     char    LeagueColourOffsets[16]={
  474.         43, 78, 64, 64, 15, 71, 15, 57, 36, 64, 50, 15, 71, 64, 64, 15,
  475.                    };
  476.  
  477. //********************************************************************************************************************************
  478.  
  479. void    DisplayBackground( int MENU )
  480.     {
  481.         LoadTexturePage( MenuBitmaps[ MENU ],            
  482.                  &EuroDATfile[0], 
  483.                  1, &FrontendTextureDEFN );
  484.  
  485.         LoadPalette( MenuPalettes[ MENU ],
  486.                  &EuroDATfile[0], 0 );
  487.         LoadPalette( BIN_MOUSEPAL,
  488.                  &EuroDATfile[0], 0 );
  489.  
  490.         switch ( MENU )
  491.         {
  492.             case( SQUAD_SELECT ):
  493.                 LoadPalette( BIN_BUL_PAL+( 8*Team ),
  494.                  &EuroDATfile[0], 16 );
  495.                 LoadPalette( FormationPalettes[Team],
  496.                  &EuroDATfile[0], 32 );
  497.                 CreateFilter( &FilterBuffer[0], 16, 16, 16, .35, .35, .35 );
  498.                 ftable    =    FilterBuffer;
  499.                 break;
  500.             case( PLAYER_STATS ):
  501.                 LoadPalette( BIN_BUL_PAL+( 8*Team ),
  502.                  &EuroDATfile[0], 16 );
  503.                 LoadPalette( FormationPalettes[Team],
  504.                  &EuroDATfile[0], 32 );
  505.                 break;
  506.  
  507.             case( TEAM_SELECT ):
  508.                 CreateFilter( &FilterBuffer[0],    40, 54, 60, .8, .8, .8);
  509.                 break;
  510.  
  511.             case( PLAYER_SETUP ):
  512.                 LoadPalette( BIN_BUL_PAL+( 8*EUROteamA ),
  513.                  &EuroDATfile[0], 16 );
  514.                 LoadPalette( BIN_BUL_PAL+( 8*EUROteamB ),
  515.                  &EuroDATfile[0], 32 );
  516.                 break;
  517.  
  518.             case( TEAM_STATS ):
  519.                 LoadPalette( BIN_TBUL_PAL+( 8*EUROstatTeam ),
  520.                  &EuroDATfile[0], 37 );
  521.                 LoadPalette( BIN_CBUL_PAL+( 8*EUROstatTeam ),
  522.                  &EuroDATfile[0], 132 );
  523.                 break;
  524.         }
  525.  
  526.         DrawIMAGE(  &FrontendBackgroundDEFN, &FrontendTextureDEFN, BACKGROUNDimge, 0, 0, NO_BOX, straightcopy );
  527.     }                   
  528.  
  529. //********************************************************************************************************************************
  530.  
  531. void    Set_palette_to_black()
  532.     {
  533.         for (short i=0;i<256;i++)
  534.         {
  535.               outp    (0x3c8,i);
  536.               outp    (0x3c9,0);
  537.               outp    (0x3c9,0);
  538.               outp    (0x3c9,0);
  539.         }
  540.         memset( CurrentPalette, 0, 768 );
  541.     }
  542.  
  543. //********************************************************************************************************************************
  544.  
  545. short    ControlSlider( slider_info *slider, short xposn, short yposn, short buttons )
  546.     {
  547.         float    offset;
  548.  
  549.         CopyFromBACKtoPSEUDObuffer(
  550.             &FrontendPseudoDEFN, &FrontendBackgroundDEFN,
  551.             slider->minx-6, slider->miny-9, 
  552.                 Image_Widths[SLDR_CURS], slider->maxy-slider->miny+Image_Heights[SLDR_CURS] );
  553.  
  554.         if ( xposn > (slider->minx-16)
  555.               && xposn < (slider->maxx+16)
  556.                && yposn > slider->miny-8
  557.             && yposn < slider->maxy+8 && buttons != 0 )
  558.             {
  559.                  if ( yposn < slider->maxy )
  560.                 {
  561.                     if ( yposn < slider->miny )
  562.                         slider->windowposn = 0;                    
  563.                     else
  564.                         slider->windowposn = yposn-slider->miny;
  565.                 }
  566.  
  567.                 else
  568.                     slider->windowposn = slider->maxy-slider->miny;
  569.             }
  570.  
  571.           DrawIMAGE( &FrontendPseudoDEFN, &FrontendTextureDEFN, SLDR_CURS, 
  572.             (slider->minx-6), ( (slider->windowposn+slider->miny)-9), 
  573.             NO_BOX, spritecopy );      
  574.  
  575.         AddToDumpList( (slider->minx-6), (slider->miny-9), 
  576.             Image_Widths[SLDR_CURS], slider->maxy-slider->miny+Image_Heights[SLDR_CURS] );
  577.  
  578.         offset    = (((float)(slider->elements-slider->page_elements))/ 
  579.               ((float)(slider->maxy-slider->miny)))* 
  580.               ((float)slider->windowposn);
  581.         return( (short)offset );
  582.     }
  583.  
  584. //********************************************************************************************************************************
  585.  
  586. void    Set_640x480_VideoMode()
  587.     {
  588.         // set the video mode to mode 101 (640x480).
  589.  
  590.         testVESA        =    0;    
  591.         EuroVideoStatus        =    VESAmode( &EUROvideoMode[0] );
  592.     }
  593.  
  594. //********************************************************************************************************************************
  595.  
  596. void    Test_640x480_VideoMode()
  597.     {
  598.         // tests for video mode 101 (640x480).
  599.  
  600.         testVESA        =    1;    
  601.         EuroVideoStatus        =    VESAmode( &EUROvideoMode[0] );
  602.         if ( EuroVideoStatus == -1 )
  603.                   printf("˛ Video mode unavailable.\n");
  604.         else
  605.                   printf("˛ Video mode initialised.\n");
  606.     }
  607.  
  608. //********************************************************************************************************************************
  609. //
  610. //    BUTTON HIGHLIGHT CONTROLLER:
  611. //
  612. //    Entry:        BOX        Normal BOX value.         
  613. //            CHKBOX1        First box to be checked (button box).
  614. //            CHKBOX2        Second box to be checked (text display box).
  615. //               HIGH        Current highlight value ( -1, 15 or 29 ). A change in HIGH value from previous
  616. //                    HIGH value means string is to be reprinted.
  617. //            BUTHANDLE    Handle variable used for this selection button.
  618. //                    
  619. //                    
  620. //                    
  621. //    Returns:    New Highlight value.
  622. //
  623. //
  624. //
  625. //
  626.  
  627. #define    textxoff    52
  628. #define    textyoff    8
  629.  
  630. char    ControlOptionHighlight( signed char BOX, signed char CHKBOX1, signed char CHKBOX2, 
  631.                  char HIGH, short BUTHANDLE, short TEXT )
  632.     {
  633.          char    PAL    =    -1;
  634.  
  635.          if ( BOX == CHKBOX1 || BOX == CHKBOX2 )
  636.              PAL    =    OVERRIDEpal1;
  637.          else
  638.              PAL    =    OVERRIDEpal2;
  639.  
  640.          if ( PAL != HIGH )
  641.          {
  642.              CopyFromBACKtoPSEUDObuffer( &FrontendPseudoDEFN, &FrontendBackgroundDEFN,
  643.                  Bounding_table[ CHKBOX1 ].BoundingBoxRight,
  644.                 Animation_table[BUTHANDLE].yposn+textyoff,
  645.                 639-Bounding_table[ CHKBOX1 ].BoundingBoxRight, 28 );
  646.  
  647.              DisplayString(  
  648.                 Animation_table[BUTHANDLE].xposn+textxoff,
  649.                 Animation_table[BUTHANDLE].yposn+textyoff,
  650.                 GetTEXT ( TEXT ),
  651.                 MEDIUM_FONT, (int)PAL, CHKBOX2, &FrontendPseudoDEFN, &FrontendTextureDEFN  );
  652.  
  653.              AddToDumpList( 
  654.                  Bounding_table[ CHKBOX1 ].BoundingBoxRight,
  655.                 Animation_table[BUTHANDLE].yposn+textyoff,
  656.                 639-Bounding_table[ CHKBOX1 ].BoundingBoxRight, 28 );
  657.  
  658.         }
  659.  
  660.     Bounding_table[ CHKBOX2 ].BoundingBoxLeft =
  661.         Bounding_table[ CHKBOX1 ].BoundingBoxRight;
  662.  
  663.     OVERRIDEpal1    =    15;
  664.     OVERRIDEpal2    =    29;
  665.     HIGH        =     PAL;
  666.     return(HIGH);
  667.     }
  668.  
  669. //********************************************************************************************************************************
  670.  
  671. char    *LowerCaseString( char *string )
  672.     {
  673.         char    Searchlen    =    strlen(&string[0]);
  674.  
  675.         for ( char x=1; x<Searchlen ; x++ )
  676.         {
  677.             if ( *(string+(x-1))!=' ' )
  678.                 *(string+x) = ToLower[*(string+x)];
  679.         }
  680.  
  681.     return(string);        
  682.     }
  683.  
  684. //********************************************************************************************************************************
  685.  
  686. char    *GetTEAMname( char team, char maxlen )
  687.     {
  688.         char    *Name        =    GetTEXT( TEAM_NMES+team );
  689.         char    Searchlen    =    strlen(&Name[0]);
  690.         char    NAMEoffset    =    0;
  691.  
  692.         for ( char x=0; x<Searchlen ; x++ )
  693.             {StringBuffer[x]     = * (Name+x);}
  694.         StringBuffer[x]     = 0;
  695.  
  696.         if ( maxlen!=0 && Searchlen > maxlen )
  697.             {
  698.                 StringBuffer[maxlen-1] = '.';
  699.                 StringBuffer[maxlen] = 0;
  700.             }
  701.  
  702.     return    ( &StringBuffer[0] );
  703.     }
  704.  
  705. //********************************************************************************************************************************
  706.  
  707. short    GetTemplete( char *buf, short soff )
  708.     {
  709.         char    Toffset    = 0;                    
  710.  
  711.         if ( buf[soff] == '?' )
  712.         {
  713.             soff++;
  714.             
  715.             while ( buf[soff]!=' ' )
  716.             {
  717.                 Templete[Toffset] = buf[soff];
  718.                 if (Toffset<127)
  719.                     Toffset++;
  720.                 soff++;
  721.             }
  722.  
  723.             Templete[Toffset] = 0;
  724.             strupr( Templete );            
  725.         }
  726.  
  727.     return(soff);
  728.        }
  729.  
  730. //********************************************************************************************************************************
  731.  
  732. char    *StringTemplete( short text, char flagA )
  733.     {
  734.         short soff     = 0;        // input string.
  735.         char *string     = GetTEXT( text );
  736.         char Build[128];
  737.         BuildBuffer[0]    = 0;
  738.         
  739.         while ( string[soff]!=0 )
  740.         {
  741.             Build[0] = 0;
  742.  
  743.             if ( string[soff] == '?' )
  744.             {
  745.                 soff = GetTemplete( &string[0], soff );                
  746.  
  747.                 if ( !strcmp( Templete, "WINTEAM") )
  748.                     strcpy( Build, LowerCaseString(GetTEAMname( Results[flagA].WinningTeam, 11)));
  749.  
  750.                 if ( !strcmp( Templete, "WINPENS") )
  751.                 {
  752.                     if ( Results[flagA].HomePens > Results[flagA].AwayPens )
  753.                                itoa( (int)Results[flagA].HomePens, Build, 10);
  754.                     else                          
  755.                                itoa( (int)Results[flagA].AwayPens, Build, 10);
  756.                 }
  757.  
  758.                 if ( !strcmp( Templete, "LOSEPENS") )
  759.                 {
  760.                     if ( Results[flagA].HomePens < Results[flagA].AwayPens )
  761.                                itoa( (int)Results[flagA].HomePens, Build, 10);
  762.                     else                        
  763.                                itoa( (int)Results[flagA].AwayPens, Build, 10);
  764.                 }
  765.  
  766.                 strcat( BuildBuffer, Build);
  767.             }                                    
  768.             
  769.             else
  770.  
  771.             {
  772.                 Build[0] = * (string+soff);
  773.                 Build[1] = 0;
  774.                 strcat( BuildBuffer, Build);
  775.                 soff++;
  776.             }
  777.  
  778.         }
  779.  
  780.     return( &BuildBuffer[0] );
  781.     }
  782.  
  783. //********************************************************************************************************************************
  784.